package demo.db.mysql.vo;

public class BinlogInfo {

    private String fileName;

    private Long position;

    private Long nextPosition;

    private Long lastUpdateTime;

    public BinlogInfo() {

    }

    public BinlogInfo(String fileName, Long position, Long nextPosition) {
        this.fileName = fileName;
        this.position = position;
        this.nextPosition = nextPosition;
    }

    /**
     * @return the fileName
     */
    public String getFileName() {
        return fileName;
    }

    /**
     * @param fileName the fileName to set
     */
    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    /**
     * @return the position
     */
    public Long getPosition() {
        return position == null ? nextPosition : position;
    }

    /**
     * @param position the position to set
     */
    public void setPosition(Long position) {
        this.position = position;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;

        BinlogInfo that = (BinlogInfo) o;

        if (!fileName.equals(that.fileName))
            return false;
        if (!nextPosition.equals(that.nextPosition))
            return false;
        if (!position.equals(that.position))
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = fileName.hashCode();
        result = 31 * result + position.hashCode();
        result = 31 * result + nextPosition.hashCode();
        return result;
    }

    /**
     * @return the nextPosition
     */
    public Long getNextPosition() {
        return nextPosition;
    }

    /**
     * @param nextPosition the nextPosition to set
     */
    public void setNextPosition(Long nextPosition) {
        this.nextPosition = nextPosition;
    }

    @Override
    public String toString() {
        StringBuilder str = new StringBuilder("{");
        str.append("fileName:").append(fileName).append(", position:").append(position).append(", nextPosition:")
                .append(nextPosition).append("}");
        return str.toString();
    }

    /**
     * @return the lastUpdateTime
     */
    public Long getLastUpdateTime() {
        return lastUpdateTime;
    }

    /**
     * @param lastUpdateTime the lastUpdateTime to set
     */
    public void setLastUpdateTime(Long lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
    }
}
